import React, { Component } from 'react';

import StatisticalCard from './components/StatisticalCard';
import MonthLine from './components/MonthLine';
import ChannelRealLine from './components/ChannelRealLine';
import { getUser } from '../../auth'
import { TaskService } from '../../services'



export default class Dashboard extends Component {
  static displayName = 'Dashboard';

  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount = async() =>{
    let user = getUser()
    let status = await TaskService.status()
    let groupMonth = await TaskService.groupMonth()
    let groupChannel = await TaskService.groupChannel()
    this.setState({ loading : false, groupMonth : groupMonth, groupChannel : groupChannel, status : status })
  }

  render() {
    return (
      <div className="dashboard-page">
        <StatisticalCard status={this.state.status}/>
        <MonthLine data={this.state.groupMonth}/>
        <ChannelRealLine data={this.state.groupChannel}/>
      </div>
    );
  }
}
